package com.qlk.odcinterface.manager.impl;

import java.util.List;

import com.qlk.common.manager.BaseManager;
import com.qlk.common.utils.page.PageUtil;
import com.qlk.odcinterface.domain.PmsFullCutItem;
import com.qlk.odcinterface.domain.query.PmsFullCutItemQuery;
import com.qlk.odcinterface.dao.PmsFullCutItemDao;
import com.qlk.odcinterface.manager.PmsFullCutItemManager;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * PmsFullCutItemManager接口的实现类
 * 
 * @author zhaoyanan
 * @version 2016-4-14 13:22:58
 * 
 */
@Component
public class PmsFullCutItemManagerImpl extends BaseManager implements PmsFullCutItemManager {
	
    @Autowired
    private PmsFullCutItemDao pmsFullCutItemDao;

    /**
     * {@inheritDoc}
     */
    public boolean insert(final List<PmsFullCutItem> pmsFullCutItemList) {
        boolean resultFlag = false;
        if (null != pmsFullCutItemList && pmsFullCutItemList.size() > 0) {
            for (PmsFullCutItem pmsFullCutItem : pmsFullCutItemList) {
                resultFlag = pmsFullCutItemDao.insert(pmsFullCutItem);
                if (!resultFlag) {
                    throw new RuntimeException("批量新增表信息异常");
                }
            }
        }

        return resultFlag;
    }

    /**
     * {@inheritDoc}
     */
    public boolean insert(PmsFullCutItem pmsFullCutItem) {
        return pmsFullCutItemDao.insert(pmsFullCutItem);
    }

    /**
     * {@inheritDoc}
     */
    public boolean update(final PmsFullCutItem pmsFullCutItem) {
        return pmsFullCutItemDao.update(pmsFullCutItem);
    }

    /**
     * {@inheritDoc}
     */
    public List<PmsFullCutItem> queryPmsFullCutItemList(PmsFullCutItemQuery queryBean) {
        return pmsFullCutItemDao.queryPmsFullCutItemList(queryBean);
    }

    /**
     * {@inheritDoc}
     */
    public List<PmsFullCutItem> queryPmsFullCutItemListWithPage(PmsFullCutItemQuery queryBean,
            PageUtil pageUtil) {
        if (null == queryBean) {
            queryBean = new PmsFullCutItemQuery();
        }

        // 查询总数
        int totalItem = queryPmsFullCutItemCount(queryBean);

        if (pageUtil == null) {
            pageUtil = new PageUtil();
        }
        pageUtil.setTotalRow(totalItem);
        pageUtil.init();
        
        if (totalItem > 0) {
            queryBean.setPageIndex(pageUtil.getCurPage());
            queryBean.setPageSize(pageUtil.getPageSize());
            // 调用Dao翻页方法
            return pmsFullCutItemDao.queryPmsFullCutItemListWithPage(queryBean);
        }
        return null;
    }

    /**
     * {@inheritDoc}
     */
    public int queryPmsFullCutItemCount(PmsFullCutItemQuery queryBean) {
        return pmsFullCutItemDao.queryPmsFullCutItemCount(queryBean);
    }

    /**
     * {@inheritDoc}
     */
    public boolean delete(PmsFullCutItem pmsFullCutItem) {
        return pmsFullCutItemDao.delete(pmsFullCutItem);
    }

    /**
     * {@inheritDoc}
     */
    public PmsFullCutItem getPmsFullCutItemById(Long id) {
        return pmsFullCutItemDao.getPmsFullCutItemById(id);
    }

    /**
     * {@inheritDoc}
     */
    public boolean delete(final PmsFullCutItem[] pmsFullCutItems) {
        boolean resultFlag = false;
        if (null != pmsFullCutItems && pmsFullCutItems.length > 0) {
            for (int i = 0; i < pmsFullCutItems.length; i++) {
                resultFlag = delete(pmsFullCutItems[i]);
                if (!resultFlag) {
                    throw new RuntimeException("批量删除表信息异常!");
                }
            }
        }

        return resultFlag;
    }

    /**
     * {@inheritDoc}
     */
    public boolean exist(PmsFullCutItem pmsFullCutItem) {
        return pmsFullCutItemDao.exist(pmsFullCutItem);
    }
}
